﻿using XNAFight.Scene.Core;
using XNAFight.Scene.SandBoxOne;
using Microsoft.Xna.Framework;
using System;

namespace XNAFight.Scene.OutGame
{
    public class MenuPrincipal : MenuScreen
    {
        #region CHAMPS

        SandBoxOneCharacterSelect to_sandbox;
        OptionMenu options;
        ToolsMenu tools;
        
        #endregion

        #region PROPRIETES
        
        #endregion

        #region INITIALISATION

        public MenuPrincipal(string _title)
            : base(_title)
        {
            to_sandbox = new SandBoxOneCharacterSelect();
            options = new OptionMenu("Options");
            tools = new ToolsMenu("Tools");

            items = new TextMenuItem[1, 4];

            MenuItem sand_box_MI = new TextMenuItem(new Vector2(20, 70), "Sand Box", 0.8f);
            MenuItem tools_MI = new TextMenuItem(new Vector2(20, 90), "Tools", 0.8f);
            MenuItem options_MI = new TextMenuItem(new Vector2(20, 110), "Options", 0.8f);
            MenuItem quit_MI = new TextMenuItem(new Vector2(20, 130), "Quitter", 0.8f);

            items[0, 0] = sand_box_MI;
            items[0, 1] = tools_MI;
            items[0, 2] = options_MI;
            items[0, 3] = quit_MI;
            
            sand_box_MI.Selected += this.Complete;
            sand_box_MI.Selected += to_sandbox.Add;
            to_sandbox.Cancelled += this.Add;
            to_sandbox.Completed += outGameComplete;

            options_MI.Selected += this.Complete;
            options_MI.Selected += options.Add;
            options.Removed += this.Add;

            tools_MI.Selected += this.Complete;
            tools_MI.Selected += tools.Add;
            tools.Cancelled += this.Add;
            tools.to_ToolAnime.Completed += outGameComplete;
            
            quit_MI.Selected += quitSelected;

            this.Adding += Reset;
            this.Added += this.Activate;
            this.Removed += this.Disable;
        }
        #endregion

        #region UPDATE / DRAW
        
        public override void Draw(GameTime _game_time)
        {
            GraphicsDevice.Clear(Color.White);
            base.Draw(_game_time);
        }

        #endregion

        #region AUTRES METHODES

        private void outGameComplete(object _sender, EventArgs _e)
        {
            complete = true;
            Remove();
        }

        private void quitSelected(object _sender, EventArgs _e)
        {
            Game.Exit();
        }

        #endregion
    }
}
